|
|
|
|
|
|
|
Byte Versus Integer Data Types |
|
|
|
|
|
|
|
|
Going by the size of a data type does not always mean much. It would stand to reason that the smaller the data type, the faster it can be manipulated. This does not seem to be the case with the Byte data type. In fact, in my testing, I found that accessing a Byte data type was about 40 to 50 percent slower than accessing an Integer data type. This may be because a 32-bit operating system is used to dealing with two to four bytes at a time, and accessing just one byte may take extra time. |
|
|
|
|
|
|
|
|
Fixed Strings Versus Dynamic Strings |
|
|
|
|
|
|
|
|
Visual Basic creates most strings on-the-fly. This can result in a lot of overhead for sizing and resizing strings. In fact, if you test setting a value into a fixed string versus setting it into a dynamic string, the fixed string can be set about 40 percent faster. Because theres no overhead for reallocating memory, it makes sense that a fixed string can be written faster than a dynamic string. |
|
|
|
|
|
|
|
|
Specific Object Types Versus Generic Object Types |
|
|
|
|
|
|
|
|
If youre passing controls from a form to a generic routine that does something with these controls, its much better to use the specific object type as opposed to a generic type such as Control. This means you should declare your arguments like this: |
|
|
|
 |
|
|
|
|
Private Sub SpecificPass(ctl As ComboBox)
End Sub |
|
|
|
|
|
|
|
|
Avoid using an argument like the following: |
|
|
|
 |
|
|
|
|
Private Sub GenericPass(ctl As Control)
End Sub |
|
|
|
|
|
|
|
|
This is faster because the compiler can resolve what the type of the control is at compile time, whereas the generic type has to be resolved at runtime. This takes extra time while the program is running and therefore makes it slower. |
|
|
|
|
|